<!--
    统计分析
    梁
    2019年5月11日
    -->
<template lang="pug">
  kalix-master
    div.box
      div.boxLeft
        UserUnit
        Personage
      div.boxRight
        h1 统计分析
        div.boxTitle1.divTitle
          img(src="/static/statistics/u13444.png")
          span 已开设课程
          i 3
          p 门
        div.boxTitle2.divTitle
          img(src="/static/statistics/u13455.png")
          span 已发布的考试
          i 1
          p 门
        div.boxTitle3.divTitle
          img(src="/static/statistics/u13466.png")
          span 已发布的作业
          i 1
          p 门
        div.boxTitle4.divTitle
          img(src="/static/statistics/u13475.png")
          span 课程好评率
          i 95%
        div.inside
          div.main(ref="inside")
        div.bar
          div.main(ref="bar")
    div.clearfix
</template>

<script type="text/ecmascript-6">
  export default {
    name: 'Statistics',
    data() {
      return {}
    },
    mounted() {
      this.insideCharts()
      this.barCharts()
      this.lineCharts()
    },
    methods: {
      lineCharts() {
      },
      insideCharts() {
        let myChart = this.$echarts.init(this.$refs.inside)
        console.log(this.$refs.chart)
        // 绘制图表
        myChart.setOption({
          title: {text: '课程观看人数'},
          // 鼠标悬浮到图上，可以出现标线和刻度文本。
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'line',
              label: {
                backgroundColor: '#6a7985'
              }
            }
          },
          grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
          },
          dataZoom: [{
            type: 'inside',
            start: 100,
            end: 0
          }, {
            start: 0,
            end: 10,
            handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
            handleSize: '80%',
            handleStyle: {
              color: '#fff',
              shadowBlur: 3,
              shadowColor: 'rgba(0, 0, 0, 0.6)',
              shadowOffsetX: 2,
              shadowOffsetY: 2
            }
          }],
          xAxis: {
            data: ['0:00', '2:00', '4:00', '6:00', '8:00', '10:00', '12:00', '14:00', '16:00', '18:00', '20:00', '22:00', '24:00']

          },
          yAxis: {
            // data: [50, 100, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700]
            // max: value
            type: 'value'
          },
          series: [{
            name: '销量',
            type: 'line',
            axisLabel: {
              formatter: '{value} :00'
            },
            data: [20, 100, 200, 100, 50, 700, 600, 305, 90, 100, 60, 70, 98, 300, 500, 200, 180, 160, 150, 190, 120, 80, 100]
          }]
        })
      },
      barCharts() {
        let myChart = this.$echarts.init(this.$refs.bar)
        console.log(this.$refs.chart)
        // 绘制图表
        myChart.setOption({
          title: {text: '课程成绩'},
          // 鼠标悬浮到图上，可以出现标线和刻度文本。
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'line',
              label: {
                backgroundColor: '#6a7985'
              }
            }
          },
          grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
          },
          dataZoom: [{
            type: 'inside',
            start: 100,
            end: 0
          }, {
            start: 0,
            end: 10,
            handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
            handleSize: '80%',
            handleStyle: {
              color: '#fff',
              shadowBlur: 3,
              shadowColor: 'rgba(0, 0, 0, 0.6)',
              shadowOffsetX: 2,
              shadowOffsetY: 2
            }
          }],
          xAxis: {
            data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋', '高跟鞋']
          },
          yAxis: {
            type: 'value'
          },
          series: [{
            name: '销量',
            type: 'bar',
            color: '#FF9933',
            axisLabel: {
              formatter: '{value} :00'
            },
            data: [10, 10, 12, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
          }]
        })
      }
    },
    echarts() {
      var base = +new Date(1968, 9, 3)
      var oneDay = 24 * 3600 * 1000
      var date = []

      var data = [Math.random() * 300]
      for (var i = 1; i < 20000; i++) {
        var now = new Date(base += oneDay)
        date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'))
        date.push(Math.round((Math.random() - 0.5) * 20 + data[i - 1]))
      }
      // ECharts.setOption(option)
      console.log('base:', base)
      console.log('oneDay:', oneDay)
      console.log('data:', data)
    }
  }
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
  .clearfix::after
    content ""
    clear both
    display block
    overflow hidden
    font-size 0
    height 0

  .box
    width 1200px
    margin 5px auto

  h1
    font-size 20px
    color #FF9933
    margin-bottom 18px

  .boxRight
    width 926px
    height 1471px
    border 1px solid #ccc
    border-radius 5px
    float right
    padding 20px 20px 0 24px
    box-sizing border-box

  .boxLeft
    width 247px
    height 1471px
    float left

  .boxLeftBottom
    width 247px
    height 1140px
    .personage
      display block
      width 247px
      height 60px
      line-height 60px
      text-align center
      border 1px solid #ccc
      background-color #F2F2F2
      cursor pointer
      position relative
      -o-user-select none /*文字禁止被选中*/
      -moz-user-select none /*火狐 firefox*/
      -webkit-user-select none /*webkit浏览器*/
      -ms-user-select none /*IE10+*/
      -khtml-user-select none /*早期的浏览器*/
      user-select none
      .icon
        position absolute
        width 20px
        height 20px
        top 1px
        left 56px
        font-size 22px
        color #333333
    .listBorder
      border none
      border-left 4px solid #FF9933
      background-color #fff
      span
        color #FF9933 !important
    .text
      color #666666
      font-size 18px

  .divTitle
    width 200px
    height 100px
    display inline-block
    border-radius 5px
    margin-right 14px
    position relative
    img
      width 70px
      height 70px
      display inline-block
      margin-left 20px
      margin-top 18px
    span
      position absolute
      top 24px
      left 100px
      font-size 14px
      color #fff
    i
      position absolute
      top 45px
      left 120px
      font-size 34px
      color #fff
    p
      position absolute
      top 62px
      left 150px
      font-size 14px
      color #fff

  .boxTitle1
    background-color #56B8CE

  .boxTitle2
    background-color #FFD066

  .boxTitle3
    background-color #657DD6

  .boxTitle4
    background-color #FFB266
    i
      position absolute
      top 45px
      left 100px
      font-size 34px
      color #fff

  .main
    width 880px
    height 500px
</style>
